package com.mallcai.bigdata.ladon.datasource;

import com.mallcai.bigdata.ladon.dpl.entity.common.Datasource;
import com.mallcai.bigdata.ladon.dpl.vo.DatasourceType;
import tk.mybatis.mapper.util.Assert;

/**
 * Created by oneape<oneape15@163.com>
 * Created 2019-06-05 10:30.
 * Modify:
 */
public class HandlerFactory {

    public static AbstractJdbcHandler getHandler(Datasource ds) {
        Assert.isTrue(ds != null, "数据源信息为NULL");
        DatasourceType dt = DatasourceType.getByCode(ds.getType());
        if (dt == DatasourceType.ElasticSearch) {
            return new ElasticsearchHandler();
        } else if (dt == DatasourceType.MySQL) {
            return new MySQLHandler();
        }

        return null;
    }
}
